package com.bond.cloud.feign;

import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * 服务降级
 * FallbackClass 不可以对远程调用的异常做处理
 * FallbackFactory 可以对远程调用的异常做处理
 */
@Component
public class UserFeignFallbackFactory implements FallbackFactory<UserFeignClient> {

    @Override
    public UserFeignClient create(Throwable cause) {
        return new UserFeignClient() {
            @Override
            public String post() {
                return "这是服务降级";
            }
        };
    }
}
